Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
25 lines (21 loc) · 619 Bytes

3.4.2 - Coroutine/Http/Client->get.md

File metadata and controls

25 lines (21 loc) · 619 Bytes

Coroutine\Http\Client->get

发起GET请求,函数原型:

function Swoole\Coroutine\Http\Client->get(string $path);
  • $path 设置URL路径,如/index.html,注意这里不能传入http://domain
  • 使用get会忽略setMethod设置的请求方法,强制使用GET

使用实例

$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 80);
$cli->setHeaders([
	'Host' => "localhost",
	"User-Agent" => 'Chrome/49.0.2587.3',
	'Accept' => 'text/html,application/xhtml+xml,application/xml',
	'Accept-Encoding' => 'gzip',
]);

$cli->get('/index.php');
echo $cli->body;
$cli->close();